<template>
	<view class="content-header">
		<view class="header" v-if="orderInfo!=null">
			<view class="goods">
				<view class="goods-top">
					<view class="goods-ones flex-row flex-content-between" v-for="good in orderInfo.orderitem">
						<view class="flex-row goods-ones-left">
							<image :src="$utils.cdnImg(good.image)" mode="scaleToFill"></image>
							<view class="flex-column goods-ones-left-txt">
								<view>{{good.title}}</view>
								<view class="zhongjian flex-row">
									<view v-for="tag in good.tags">{{tag.title}}</view>
								</view>
								<view>￥{{good.price}}</view>
							</view>
						</view>
						<view class="flex-column-reverse">
							<view>x{{good.num}}</view>
						</view>
					</view>
					
					
					<view class="order-no flex-row flex-content-between">
						<view class="flex-row" v-if="orderInfo.express">
							<view class="order-no-1">{{orderInfo.express.name}}：</view>
							<view class="order-no-2">{{orderInfo.express_num}}</view>
							</view>
						<view class="order-no-3" @tap="fuzhi(orderInfo.express_num)">复制</view>
					</view>
					
				</view>
			</view>
			<view class="address">
				<view class="address-top">
					<uni-section title="物流信息" type="line" padding="24rpx">
								<uni-steps :options="list2" active-color="#007AFF" :active="active" direction="column" />
							</uni-section>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				order_num:"",
				orderInfo:null,
				list2: [],
				active:1,
			}
		},
		onLoad(opt) {
			// console.log(opt);
			if(opt.order_num){
				this.order_num = opt.order_num
			}
			this.getOrderInfo();
		},
		methods:{
			//复制快递单号
			fuzhi(express_num){
				let that = this;
				if(!express_num){
					express_num = this.orderInfo.express_num;
				}
				uni.setClipboardData({
					data:express_num,
					success() {
						that.$utils.showMessage("复制成功")
					},
					fail() {
						that.$utils.showMessage("复制失败")
					}
				})
			},
			//获取订单那详情
			getOrderInfo(){
				let data = {
					order_num:this.order_num
				}
				let that = this;
				this.$api.getOrderInfo(data).then(res=>{
					// console.log(res);
					that.orderInfo = res;
					that.getExpressLogs();
				})
			},
			//获取物流记录
			getExpressLogs(){
				let that = this;
				this.$api.getExpressLogs({
					order_id:this.orderInfo.id
				}).then(res=>{
					let list2 = []
					if(res.length>0){
						res.forEach(item=>{
							list2.push({
								title:item.notes+item.address,
								desc:item.createtime
							})
						})
						that.list2 = list2
					}
					// console.log(res);
				})
			}
		}
	}
</script>

<style lang="scss">
	.address-top{
		margin-left: 28rpx;
		padding-top: 34rpx;
		margin-right: 53rpx;
		padding-bottom: 32rpx;
	}
	.address{
		width: 690rpx;
		// height: 300rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		margin-top: 20rpx;
	}
	.order-no-1{
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		margin-left: 20rpx;
	}
	.order-no-2{
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
	}
	.order-no-3{
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		margin-right: 20rpx;
	}
	.order-no{
		width: 650rpx;
		height: 65rpx;
		background: #FFF9EC;
		border-radius: 10rpx 10rpx 10rpx 10rpx;
		opacity: 1;
		line-height: 65rpx;
	}
	.zhongjian{
		margin-top: 10rpx;
		>view{
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FF5000;
			height: 38rpx;
			background: #FFFFFF;
			border-radius: 8rpx 8rpx 8rpx 8rpx;
			opacity: 1;
			border: 1px solid #FF5000;
			padding: 0rpx 10rpx 0rpx 10rpx;
			text-align: center;
			line-height: 38rpx;
			margin-right: 10rpx;
		}
	}
	.goods-ones-left-txt{
		margin-left: 20rpx;
		>view:nth-child(1){
			font-size: 28rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
		}
		>view:nth-child(2){
			height: 40rpx;
			// width: 200rpx;
		}
		>view:nth-child(3){
			font-size: 30rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #333333;
			margin-top: 38rpx;
		}
	}
	.goods-ones-left{
		>image{
			width: 172rpx;
			height: 172rpx;
		}
	}
	.goods-ones{
		margin-bottom: 20rpx;
	}
	.goods-top{
		padding-top: 30rpx;
		margin-left: 20rpx;
		margin-right: 20rpx;
		padding-bottom: 20rpx;
	}
	.goods{
		width: 690rpx;
		// height: 327rpx;
		background: #FFFFFF;
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		opacity: 1;
	}
	.header{
		width: 690rpx;
		margin-left: 30rpx;
	}
</style>